package com.boil.util;

import org.hibernate.annotations.common.util.StringHelper;
import org.hibernate.cfg.ImprovedNamingStrategy;

/**
 * Created by ChenYong on 2017-06-27.
 * <br>
 * Hibernate 命名策略。
 */
public class HibernateNamingStrategy extends ImprovedNamingStrategy {
    public String classToTableName(String className){
        return StringHelper.unqualify(className).toUpperCase()+'S';
    }

    public String propertyToColumnName(String propertyName){
        return propertyName.toUpperCase();
    }

    public String tableName(String tableName){
        return tableName;
    }

    public String columnName(String columnName){
        return columnName;
    }

    public String propertyToTableName(String className,String propertyName){
        return classToTableName(className)+'_'+propertyToColumnName(propertyName);
    }
}